﻿@model IEnumerable<Developer.Entity.OrderTemps>

@{ 
    Layout = "~/Views/Shared/_PopLayout.cshtml";
    var i = 1;
}
<link href="~/Content/UI/css/mui.min.css" rel="stylesheet" />
<link href="~/Content/UI/css/mdui.min.css" rel="stylesheet" />
<div class="page-container">
    @*<div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"> <a href="javascript:;" onclick="sf_show('添加角色', '/admin/Role/Edit', '', '420',true)" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加角色</a> </span> <span class="r">共有数据：<strong>@ViewBag.itemCount</strong> 条</span> </div>*@
    <div class="mt-20">
        <table class="table table-border table-bordered table-hover table-bg table-sort">
            <thead>
                <tr class="text-c">
                    <th>序号</th>
                    <th>书本名称</th>
                    <th>预定价格</th>
                    <th>删除</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model)
                {
                    <tr class="text-c">
                        <td id="companyId">@(i++)</td>
                        <td>@item.Books.Name</td>
                        <td>@item.Books.OrderPrice</td>
                        <td class="td-manage">
                            <a title="删除" href="javascript:;" onclick="sf_del('/book/deleteorder?Id=@(item.Id)')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
                            @*<a title="删除" href="javascript:;" onclick="sf_del('/admin/Role/Delete?Id=@(item.Id)')" class="ml-5 btn btn-primary radius" style="text-decoration: none">删除</a>*@
                        </td>
                    </tr>
                }
            </tbody>
        </table>
        
        <div style="clear:both;"></div>

        <button type="button" class="mui-btn" onclick="SureOrder();">确认订购 <span class="mui-badge">@Model.Count()</span></button>
    </div>
</div>
<script src="~/Content/UI/js/mui.min.js"></script>
<script src="~/Content/UI/js/mdui.min.js"></script>
<script src="~/Content/scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>

<script>
    function SureOrder() {
        $.ajax({
            url: '/Book/AddBorrowing',
            dataType: 'Json',
            type: 'POST',
            data: { 'uid': localStorage.user },
            success: function(data){
                mdui.snackbar({
                    message: '预定成功！',
                    buttonText: '返回',
                    onClick: function () {
                        self.location = "/Index/Home";
                    },
                    onButtonClick: function () {
                        self.location = "/Index/Home";
                    },
                    onClose: function () {
                        self.location = "/Index/Home";
                    }
                });
            }
        });
    }
</script>